﻿using System;

// SIRP Experimental Firmware
// Display interface definition
// (c) 2014 Chris Burri. MIT License applies. 
// See http://niston.wordpress.com

namespace sdd.subsystems.display
{
    public interface IDisplay
    {
        // a keyboard event occured
        event EventHandler<KeypadEventArgs> KeypadEvent;
        // serial io communications port to display
        sdd.subsystems.io.ISerialIO Port { get; set; }
        // display commands
        void ActivatePiezoBuzzer(short frequencyHz, short timeMilliseconds);
        void ClearScreen();
        void ClearTextWindow(byte windowId);
        void DrawFilledRectangle(byte fillColor, byte leftPos, byte topPos, byte rightPos, byte bottomPos);
        void DrawPixel(byte xPos, byte yPos);
        void DrawLine(byte startX, byte startY, byte endX, byte endY);
        void DrawBar(byte top, byte left, byte height, byte maxWidth, byte percent);
        void Home();
        void InitializeLabel(byte labelID, byte leftPos, byte topPos, byte rightPos, byte bottomPos, JustificationVertical verticalJustification, JustificationHorizontal horizontalJustification, short fontId, byte backgroundColor, byte charSpace);
        void InitializeTextWindow(byte windowId, byte left, byte top, byte right, byte bottom, short fontId, byte charSpace, byte lineSpace, byte scroll);
        void UpdateLabel(byte labelID, string labelText);
        void Reset();
        void ScrollScreen(byte leftPos, byte topPos, byte rightPos, byte bottomPos, byte moveX, byte moveY);
        void SetAutoScroll(bool isEnabled);
        void SetBoxSpaceMode(bool clearExistingChar);
        void SetCurrentFont(short fontId);
        void SetCursorCoordinate(byte xPosition, byte yPosition);
        void SetCursorPosition(byte columnNumber, byte rowNumber);
        void SetFontMetrics(byte lineMargin, byte topMargin, byte charSpace, byte lineSpace, byte scroll);
        void SetLedBlinker(LedLocations location, bool enableBlinker);
        void SetLedIndicators(LedLocations location, LedColors color, bool forceUpdate = false);
        void SetTextWindow(byte windowId);
        void WriteText(string displayText);
    }

#region IDisplay Enums and EventArgs
    public enum LedLocations
    {
        Top = 0,
        Middle = 1,
        Bottom = 2
    }

    public enum LedColors
    {
        Dark = 0,
        Green = 1,
        Red = 2,
        Amber = 3
    }

    public enum KeypadKeys
    {
        Up = 1,
        Right = 2,
        Down = 3,
        Left = 4,
        Center = 5,
        FunctionUpper = 6,
        FunctionLower = 7
    }

    public enum JustificationVertical
    {
        Top = 0,
        Middle = 1,
        Bottom = 2
    }

    public enum JustificationHorizontal
    {
        Left = 0,
        Center = 1,
        Right = 2
    }

    public class KeypadEventArgs : EventArgs
    {
        public KeypadEventArgs(KeypadKeys key)
        {
            Key = key;
        }
        public KeypadKeys Key { get; private set; }
    }
#endregion
}
